package controller;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;

import model.AllItem;
import model.Information;
import model.SubmittedData;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
import org.apache.http.util.EntityUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import utils.CustomAuctionPeriodAdapter;
import utils.Utils;
import utils.XmlParser;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.res.AssetManager;
import android.database.DataSetObserver;
import android.os.AsyncTask;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import app.cloudstringers.All;
import app.cloudstringers.Home;
import app.cloudstringers.MyVideoTab;
import app.cloudstringers.R;
import au.com.bytecode.opencsv.CSVReader;
import define.API;
import define.Constants;
import define.DefaultValue;
import define.Key;

public class GetItemInAllTabs extends AsyncTask<Void, Void, Boolean> {

	/**
	 * String section
	 */
	private static final String TAG = GetItemInAllTabs.class.getSimpleName();

	// XML node keys
	private static final String KEY_AUCTION_PERIOD = "auction_period";
	private static final String KEY_BASE_PRICE = "base_price";
	private static final String KEY_BUY_NOW_PRICE = "buy_now";
	private static final String KEY_COUNTRY_ID = "country_id";
	private static final String KEY_DESCRIPTION = "desc";
	private static final String KEY_EXPIRY_TIME = "expiry_time";
	private static final String KEY_HIGHEST_BID = "highest_bid";
	private static final String KEY_MINIMUM_BID = "minimum_bid";
	private static final String KEY_PRICE = "price";
	private static final String KEY_SOLD = "sold";
	private static final String KEY_TAGS = "tags";
	private static final String KEY_TITLE = "title";
	private static final String KEY_TYPE = "type";
	private static final String KEY_VIDEO = "video"; // parent node
	private static final String KEY_VIDEO_ID = "video_id";

	private static String AUCTION_PERIOD = null, BASE_PRICE = null,
			BUY_NOW_PRICE = null, COUNTRY_ID = null,
			DESCRIPTION = null, EXPIRY_TIME = null, HIGHEST_BID = null,
			MINIMUM_BID = null, PRICE = null, SOLD = null, TAGS = null,
			TITLE = null, TYPE = null, ITEM_ID = null;

	/**
	 * Data section
	 */
	public static ArrayList<Information> mAlInformation = new ArrayList<Information>();
	private ArrayList<AllItem> mAlAllItem = new ArrayList<AllItem>();
	public static ArrayList<String> mAlItemID = new ArrayList<String>();

	private AllAdapter allAdapter = null;

	/**
	 * View section
	 */
	private ListView mLvAllItem;

	/**
	 * Others section
	 */
	private Utils connectivity = null;
	private Context context;
	private XmlParser mXMLParser;

	public GetItemInAllTabs(Context context) {
		this.context = context;

		connectivity = new Utils(context);

		// Initial array list
		if (connectivity.isNetworkOnline()) {
			mLvAllItem = (ListView) ((Activity) context)
					.findViewById(R.id.lv_in_all);
			allAdapter = new AllAdapter(context, R.layout.simple_list_item_all);
		}
	}

	@Override
	protected Boolean doInBackground(Void... params) {
		return getItemInformationOnMarketPlace();
	}

	@Override
	protected void onPreExecute() {
		super.onPreExecute();

		connectivity.showProgressDialog();

		if (mAlAllItem != null & mAlAllItem.isEmpty()) {
			mAlAllItem.clear();
		}
		if (allAdapter != null & !allAdapter.isEmpty()) {
			allAdapter.clear();
			allAdapter.notifyDataSetChanged();
		}
		if (mAlInformation != null && !mAlInformation.isEmpty()) {
			mAlInformation.clear();
		}
		if (mAlItemID != null && !mAlItemID.isEmpty()) {
			mAlItemID.clear();
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	protected void onPostExecute(Boolean result) {
		super.onPostExecute(result);

		if (!result)
			connectivity.showConnectionTimeoutDialog(context, Home.class);
		else {
			mAlAllItem.clear();
			switch (MyVideoTab.CURRENT_TAB) {
			case 0:
				// All collection
				mAlAllItem = (ArrayList<AllItem>) AllTabsAsync.mAlAllItem
						.clone();
				break;
			case 1:
				// Auction collection
				mAlAllItem = (ArrayList<AllItem>) AllTabsAsync.mAlAuctionItem
						.clone();
				break;
			case 2:
				// Market Place collection
				mAlAllItem = (ArrayList<AllItem>) AllTabsAsync.mAlMarketPlaceItem
						.clone();
				break;
			case 3:
				// Privacy collection
				mAlAllItem = (ArrayList<AllItem>) AllTabsAsync.mAlPrivacyItem
						.clone();
				break;
			default:
				break;
			}

			// Show data to the list view
			showDataIntoListView(mAlAllItem);
		}

		connectivity.hideProgressDialog();
	}

	public boolean getItemInformationOnMarketPlace() {
		// Get item information for All page
		String URL = API.MP_LIST_ITEMS + GetTokenString.TOKEN_STRING + "&sales_type="
				+ Constants.SALE_TYPE_ALL;

		URI mUriWebsite;
		try {
			mUriWebsite = new URI(URL);

			HttpParams mHttpParams = new BasicHttpParams();
			HttpGet mHttpGet = new HttpGet();

			mHttpGet.setURI(mUriWebsite);

			HttpClient mHttpClient = new DefaultHttpClient(mHttpParams);
			HttpResponse mHttpResponse = mHttpClient.execute(mHttpGet);

			HttpEntity mHttpEntity = mHttpResponse.getEntity();

			String XML = EntityUtils.toString(mHttpEntity);

			mXMLParser = new XmlParser();
			Document mDocument = mXMLParser.getDomElement(XML);

			// List element follow video_id key
			NodeList mNodeList = mDocument.getElementsByTagName(KEY_VIDEO);
			for (int i = 0; i < mNodeList.getLength(); i++) {
				if (mNodeList.item(i).getNodeType() == Node.ELEMENT_NODE) {
					Element element = (Element) mNodeList.item(i);

					AUCTION_PERIOD = mXMLParser.getValue(element,
							KEY_AUCTION_PERIOD);
					BASE_PRICE = mXMLParser.getValue(element, KEY_BASE_PRICE);
					BUY_NOW_PRICE = mXMLParser.getValue(element,
							KEY_BUY_NOW_PRICE);
					COUNTRY_ID = mXMLParser.getValue(element, KEY_COUNTRY_ID);
					DESCRIPTION = mXMLParser.getValue(element, KEY_DESCRIPTION);
					EXPIRY_TIME = mXMLParser.getValue(element, KEY_EXPIRY_TIME);
					HIGHEST_BID = mXMLParser.getValue(element, KEY_HIGHEST_BID);
					MINIMUM_BID = mXMLParser.getValue(element, KEY_MINIMUM_BID);
					PRICE = mXMLParser.getValue(element, KEY_PRICE);
					SOLD = mXMLParser.getValue(element, KEY_SOLD);
					TAGS = mXMLParser.getValue(element, KEY_TAGS);
					TITLE = mXMLParser.getValue(element, KEY_TITLE);
					TYPE = mXMLParser.getValue(element, KEY_TYPE);
					ITEM_ID = mXMLParser.getValue(element, KEY_VIDEO_ID);

					// New information
					Information information = new Information(AUCTION_PERIOD,
							BASE_PRICE, BUY_NOW_PRICE, COUNTRY_ID, 
							DESCRIPTION, EXPIRY_TIME, HIGHEST_BID,
							MINIMUM_BID, PRICE, SOLD, TAGS, TITLE, TYPE,
							ITEM_ID);

					// SHOT_ID & VIDEO_ID is same
					mAlItemID.add(ITEM_ID);
					mAlInformation.add(information);
				}
			}

			return true;
		} catch (URISyntaxException e) {
			e.printStackTrace();
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (ParseException e) {
			e.printStackTrace();
		} catch (ConnectTimeoutException e) {
			e.printStackTrace();
			return false;
		} catch (SocketException e) {
			e.printStackTrace();
			return false;
		} catch (SocketTimeoutException e) {
			e.printStackTrace();
			return false;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return false;
	}

	private void showDataIntoListView(ArrayList<AllItem> mAlItem) {
		for (AllItem item : mAlItem) {
			allAdapter.add(item);
		}

		mLvAllItem.setAdapter(allAdapter);

		// Notify data has changed when refreshed
		allAdapter.notifyDataSetChanged();
	}

	/**
	 * Classes
	 */
	
	public class AllAdapter extends ArrayAdapter<AllItem> {

		/**
		 * String section
		 */
		private int DEFAULT_COUNTRY_ID = 0;

		private String AUCTION_PERIOD = null;
		private String SELECTED_COUNTRY_ID = null;

		/**
		 * Data section
		 */
		private AllItem allItemAuction;
		private AllItem allItemMarketPlace;
		private SubmittedData submittedData = null;
		
		/**
		 * View section
		 */
		private Button mBtnRemoveAuction;
		private Button mBtnRemoveMarketPlace;
		private Button mBtnSubmitAuction;
		private Button mBtnSubmitMarketPlace;
		private CheckBox mCbEntertainmentAuction;
		private CheckBox mCbEntertainmentMarketPlace;
		private CheckBox mCbLifestyleAuction;
		private CheckBox mCbLifestyleMarketPlace;
		private CheckBox mCbPoliticsAuction;
		private CheckBox mCbPoliticsMarketPlace;
		private CheckBox mCbSportsAuction;
		private CheckBox mCbSportsMarketPlace;
		private CheckBox mCbTechnologyMarketPlace;
		private CheckBox mCbTechnologyAuction;
		private EditText mEtAssociationAuction;
		private EditText mEtAssociationMarketPlace;
		private EditText mEtBasePriceAuction;
		private EditText mEtBuyNowPriceAuction;
		private EditText mEtCamcorderModelAuction;
		private EditText mEtCamcorderModelMarketPlace;
		private EditText mEtCityAuction;
		private EditText mEtCityMarketPlace;
		private EditText mEtDescriptionAuction;
		private EditText mEtDescriptionMarketPlace;
		private EditText mEtJournalistIDAuction;
		private EditText mEtJournalistIDMarketPlace;
		private EditText mEtPriceMarketPlace;
		private EditText mEtTitleAuction;
		private EditText mEtTitleMarketPlace;
		private ImageButton mIbtnCancelAuction;
		private ImageButton mIbtnCancelInfo;
		private ImageButton mIbtnCancelMarketPlace;
		private ImageButton mIbtnShowAuction;
		private ImageButton mIbtnShowInfoDialog;
		private ImageButton mIbtnShowMarketPlace;
		private LinearLayout mLlExpiryTime;
		private LinearLayout mLlFixedPrice;
		private LinearLayout mLlHighestBid;
		private LinearLayout mLlMinimumBid;
		private LinearLayout mLlSold;
		private Spinner mSpinnerAuctionPeriod;
		private Spinner mSpinnerCountry;
		private TextView mTvExpiryTimeInfo;
		private TextView mTvFileName;
		private TextView mTvFixedPriceInfo;
		private TextView mTvDescriptionInfo;
		private TextView mTvFileNameInfo;
		private TextView mTvHighestBidInfo;
		private TextView mTvLastModifiedTime;
		private TextView mTvMinimumBidInfo;
		private TextView mTvPrice;
		private TextView mTvSoldInfo;
		private TextView mTvStatusInfo;
		private TextView mTvTypeAuction;
		private TextView mTvTypeMarketPlace;

		/**
		 * Listener
		 */
		private SpinnerAuctionDialogListener spinnerAuctionDialogListener = new SpinnerAuctionDialogListener();

		private OnClickListener mListenerSubmitAuction = new OnClickListener() {

			@Override
			public void onClick(View v) {
				// Check these fields not empty
				// Or check
				if ((!Utils.checkFillBlank(mEtAssociationAuction)
						& !Utils.checkFillBlank(mEtCamcorderModelAuction)
						& !Utils.checkFillBlank(mEtCityAuction)
						& !Utils.checkFillBlank(mEtDescriptionAuction)
						& !Utils.checkFillBlank(mEtJournalistIDAuction)
						& !Utils.checkFillBlank(mEtBasePriceAuction) 
						& !Utils.checkFillBlank(mEtBuyNowPriceAuction))
						| Utils.checkIntegerValue(mEtBasePriceAuction)
						| Utils.checkIntegerValue(mEtBuyNowPriceAuction)) {
					// Set these data into submitted data
					submittedData.setAssociation(mEtAssociationAuction
							.getText().toString());
					submittedData.setCamcorderModel(mEtCamcorderModelAuction
							.getText().toString());
					submittedData.setCity(mEtCityAuction.getText().toString());
					submittedData.setJournalistID(mEtJournalistIDAuction
							.getText().toString());
					submittedData.setAuctionPeriod(spinnerAuctionDialogListener
							.getAuctionPeriod());
					submittedData.setCountryID(SELECTED_COUNTRY_ID);
					submittedData.setDescription(mEtDescriptionAuction
							.getText().toString());
					submittedData.setItemID(allItemAuction.getShotid() + "");
					submittedData.setBasePrice(mEtBasePriceAuction.getText()
							.toString());
					submittedData.setBuyNowPrice(mEtBuyNowPriceAuction
							.getText().toString());
					submittedData
							.setTitle(mEtTitleAuction.getText().toString());
					submittedData.setSaleType(mTvTypeAuction.getText()
							.toString().toLowerCase(Locale.getDefault()));
					submittedData.setSelling(allItemAuction.getSellingIndex());
					
					/**
					 * Get category info to update at server
					 */
					submittedData.setTags(null);

					// Get tags
					getCheckedTagsAuction();

					new GetTokenString(context, false).execute();
					// Send data to the server
					new AddItemAsync(context).execute(submittedData);
					submittedData = null;

					// Dismiss dialog
					All.mDialogAuction.dismiss();
				} else {
					Toast.makeText(
							context,
							context.getString(R.string.toast_fill_in_the_blank),
							Toast.LENGTH_SHORT).show();
				}
			}
		};

		private OnClickListener mListenerSubmitMarketPlace = new OnClickListener() {

			@Override
			public void onClick(View v) {
				// Check these fields not empty
				// Or Price is integer value
				if ((!Utils.checkFillBlank(mEtAssociationMarketPlace)
						& !Utils.checkFillBlank(mEtCamcorderModelMarketPlace)
						& !Utils.checkFillBlank(mEtCityMarketPlace)
						& !Utils.checkFillBlank(mEtDescriptionMarketPlace)
						& !Utils.checkFillBlank(mEtJournalistIDMarketPlace) 
						& !Utils.checkFillBlank(mEtPriceMarketPlace))
						| Utils.checkIntegerValue(mEtPriceMarketPlace)) {
					// Set these data into submitted data
					submittedData.setAssociation(mEtAssociationMarketPlace
							.getText().toString());
					submittedData.setCamcorderModel(mEtCamcorderModelMarketPlace
									.getText().toString());
					submittedData.setCity(mEtCityMarketPlace.getText()
							.toString());
					submittedData.setCountryID(SELECTED_COUNTRY_ID);
					submittedData.setDescription(mEtDescriptionMarketPlace
							.getText().toString());
					submittedData.setItemID(allItemMarketPlace.getShotid());
					submittedData.setJournalistID(mEtJournalistIDMarketPlace
							.getText().toString());
					submittedData.setBasePrice(mEtPriceMarketPlace.getText()
							.toString());
					submittedData.setSaleType(mTvTypeMarketPlace.getText()
							.toString().toLowerCase(Locale.getDefault()));
					submittedData.setSelling(allItemMarketPlace
							.getSellingIndex());
					submittedData.setTitle(mEtTitleMarketPlace.getText()
							.toString());

					/**
					 * Get category info to update at server
					 */
					submittedData.setTags(null);
					
					// Get tags
					getCheckedTagsMarketPlace();

					// Send data to the server
					new AddItemAsync(context).execute(submittedData);
					submittedData = null;

					// Dismiss dialog
					All.mDialogMarketPlace.dismiss();
				} else {
					Toast.makeText(context,
							context.getString(R.string.toast_fill_in_the_blank),
							Toast.LENGTH_SHORT).show();
				}
			}
		};

		public AllAdapter(Context context, int textViewResourceId) {
			super(context, textViewResourceId);
		}

		@Override
		public View getView(final int position, View convertView,
				ViewGroup parent) {
			// Load page
			if (convertView == null) {
				LayoutInflater inflater = (LayoutInflater) context
						.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
				convertView = inflater.inflate(R.layout.simple_list_item_all,
						null);
			}

			// Begin get item
			if (mAlAllItem.get(position) != null) {
				// initial variables
				initialVariables(convertView);

				/**
				 * Check Selling Index : Private | Auction | Market Place
				 */
				checkSellingIndex(mAlAllItem.get(position));

				/**
				 * Set File Name for all items in this page
				 */
				if (mTvFileName != null) {
					mTvFileName.setText(mAlAllItem.get(position).getFileName());
				}

				/**
				 * Set Last Modified Time for all items in this page
				 */
				if (mTvLastModifiedTime != null) {
					mTvLastModifiedTime.setText(mAlAllItem.get(position)
							.getUploadTime());
				}

				// On clicked listener
				mIbtnShowAuction.setOnClickListener(new OnClickListener() {
					@Override
					public void onClick(View v) {
						getAuctionData(mAlAllItem.get(position));
					}
				});
				mIbtnShowMarketPlace.setOnClickListener(new OnClickListener() {
					@Override
					public void onClick(View v) {
						getMarketPlaceData(mAlAllItem.get(position));
					}
				});
				mIbtnShowInfoDialog.setOnClickListener(new OnClickListener() {
					@Override
					public void onClick(View v) {
						getInfoData(mAlAllItem.get(position));
					}
				});

				/**
				 * If user permission is General, hide Market Place button,
				 * Auction button If user permission is Premium, do nothing
				 */
				// If permission is 0 or 2
				// Hide Market Place button and Auction button
				if (Integer.valueOf(Home.BUYSELL) == Key.KEY_CANNOT_BUY_CANNOT_SELL
						| Integer.valueOf(Home.BUYSELL) == Key.KEY_CAN_BUY_CANNOT_SELL) {
					mIbtnShowAuction.setVisibility(View.INVISIBLE);
					mIbtnShowMarketPlace.setVisibility(View.INVISIBLE);
				}
			}

			return convertView;
		}

		@Override
		public void unregisterDataSetObserver(DataSetObserver observer) {
			if (observer != null) {
				super.unregisterDataSetObserver(observer);
			}
		}

		/**
		 * Initial methods
		 */
		private void initialData(Dialog dialog) {
			// Initial layout for dialog
			connectivity.initialFullScreenDialog(dialog);

			// Auction dialog dialog
			if (dialog == All.mDialogAuction) {
				mCbEntertainmentAuction.setChecked(false);
				mCbLifestyleAuction.setChecked(false);
				mCbPoliticsAuction.setChecked(false);
				mCbSportsAuction.setChecked(false);
				mCbTechnologyAuction.setChecked(false);
			}

			// Market place dialog
			if (dialog == All.mDialogMarketPlace) {
				mCbEntertainmentMarketPlace.setChecked(false);
				mCbLifestyleMarketPlace.setChecked(false);
				mCbPoliticsMarketPlace.setChecked(false);
				mCbSportsMarketPlace.setChecked(false);
				mCbTechnologyMarketPlace.setChecked(false);
			}
		}

		private void initialVariables(Dialog d) {
			// Auction dialog dialog
			if (d == All.mDialogAuction) {
				mBtnRemoveAuction = (Button) d
						.findViewById(R.id.btn_remove_in_auction);
				mBtnSubmitAuction = (Button) d
						.findViewById(R.id.btn_submit_in_auction);
				mCbEntertainmentAuction = (CheckBox) d
						.findViewById(R.id.cb_entertainment_in_auction);
				mCbLifestyleAuction = (CheckBox) d
						.findViewById(R.id.cb_lifestyle_in_auction);
				mCbPoliticsAuction = (CheckBox) d
						.findViewById(R.id.cb_politics_in_auction);
				mCbSportsAuction = (CheckBox) d
						.findViewById(R.id.cb_sports_in_auction);
				mCbTechnologyAuction = (CheckBox) d
						.findViewById(R.id.cb_technology_in_auction);
				mEtAssociationAuction = (EditText) d
						.findViewById(R.id.et_association_in_auction);
				mEtBasePriceAuction = (EditText) d
						.findViewById(R.id.et_base_price_in_auction);
				mEtBuyNowPriceAuction = (EditText) d
						.findViewById(R.id.et_buy_now_price_in_auction);
				mEtCamcorderModelAuction = (EditText) d
						.findViewById(R.id.et_camcoder_model_in_auction);
				mEtCityAuction = (EditText) d
						.findViewById(R.id.et_city_in_auction);
				mEtDescriptionAuction = (EditText) d
						.findViewById(R.id.et_description_in_auction);
				mEtJournalistIDAuction = (EditText) d
						.findViewById(R.id.et_journalist_id_in_auction);
				mEtTitleAuction = (EditText) d
						.findViewById(R.id.et_title_in_auction);
				mIbtnCancelAuction = (ImageButton) d
						.findViewById(R.id.ibtn_cancel_in_auction);
				mTvTypeAuction = (TextView) d
						.findViewById(R.id.tv_type_in_auction);

				mSpinnerAuctionPeriod = (Spinner) d
						.findViewById(R.id.spinner_auction_period);
			}

			// Market place dialog
			if (d == All.mDialogMarketPlace) {
				mBtnRemoveMarketPlace = (Button) d
						.findViewById(R.id.btn_remove_in_market_place);
				mBtnSubmitMarketPlace = (Button) d
						.findViewById(R.id.btn_submit_in_market_place);
				mCbEntertainmentMarketPlace = (CheckBox) d
						.findViewById(R.id.cb_entertainment_in_market_place);
				mCbLifestyleMarketPlace = (CheckBox) d
						.findViewById(R.id.cb_lifestyle_in_market_place);
				mCbPoliticsMarketPlace = (CheckBox) d
						.findViewById(R.id.cb_politics_in_market_place);
				mCbSportsMarketPlace = (CheckBox) d
						.findViewById(R.id.cb_sports_in_market_place);
				mCbTechnologyMarketPlace = (CheckBox) d
						.findViewById(R.id.cb_technology_in_market_place);
				mEtAssociationMarketPlace = (EditText) d
						.findViewById(R.id.et_association_in_market_place);
				mEtCamcorderModelMarketPlace = (EditText) d
						.findViewById(R.id.et_camcoder_model_in_market_place);
				mEtCityMarketPlace = (EditText) d
						.findViewById(R.id.et_city_in_market_place);
				mEtDescriptionMarketPlace = (EditText) d
						.findViewById(R.id.et_description_in_market_place);
				mEtJournalistIDMarketPlace = (EditText) d
						.findViewById(R.id.et_journalist_id_in_market_place);
				mEtPriceMarketPlace = (EditText) d
						.findViewById(R.id.et_price_in_market_place);
				mEtTitleMarketPlace = (EditText) d
						.findViewById(R.id.et_title_in_market_place);
				mIbtnCancelMarketPlace = (ImageButton) d
						.findViewById(R.id.ibtn_cancel_in_market_place);
				mTvTypeMarketPlace = (TextView) d
						.findViewById(R.id.tv_type_in_market_place);
			}

			if (d == All.mDialogMarketPlace) {
				mSpinnerCountry = (Spinner) d
						.findViewById(R.id.spinner_country_in_market_place);
			} else if (d == All.mDialogAuction) {
				mSpinnerCountry = (Spinner) d
						.findViewById(R.id.spinner_country_in_auction);
			}

			// Market place info dialog
			if (d == All.mDialogInfo) {
				mIbtnCancelInfo = (ImageButton) d
						.findViewById(R.id.ibtn_cancel_in_info);
				mLlExpiryTime = (LinearLayout) d
						.findViewById(R.id.ll_expiry_time);
				mLlFixedPrice = (LinearLayout) d
						.findViewById(R.id.ll_fixed_price);
				mLlHighestBid = (LinearLayout) d
						.findViewById(R.id.ll_highest_bid);
				mLlMinimumBid = (LinearLayout) d
						.findViewById(R.id.ll_minimum_bid);
				mLlSold = (LinearLayout) d.findViewById(R.id.ll_sold);
				mTvDescriptionInfo = (TextView) d
						.findViewById(R.id.tv_content_description_in_info);
				mTvExpiryTimeInfo = (TextView) d
						.findViewById(R.id.tv_content_expiry_time_in_info);
				mTvFileNameInfo = (TextView) d
						.findViewById(R.id.tv_content_file_name_in_info);
				mTvFixedPriceInfo = (TextView) d
						.findViewById(R.id.tv_content_fixed_price_in_info);
				mTvHighestBidInfo = (TextView) d
						.findViewById(R.id.tv_content_highest_bid_in_info);
				mTvMinimumBidInfo = (TextView) d
						.findViewById(R.id.tv_content_minumum_bid_in_info);
				mTvSoldInfo = (TextView) d
						.findViewById(R.id.tv_content_sold_in_info);
				mTvStatusInfo = (TextView) d
						.findViewById(R.id.tv_content_status_in_info);
			}
		}

		private void initialVariables(View view) {
			mTvFileName = (TextView) view
					.findViewById(R.id.tv_file_name_item_in_all);
			mTvLastModifiedTime = (TextView) view
					.findViewById(R.id.tv_last_modified_time_item_in_all);
			mTvPrice = (TextView) view.findViewById(R.id.tv_price_item_in_all);
			mIbtnShowAuction = (ImageButton) view
					.findViewById(R.id.ibtn_show_auction);
			mIbtnShowInfoDialog = (ImageButton) view
					.findViewById(R.id.ibtn_show_info);
			mIbtnShowMarketPlace = (ImageButton) view
					.findViewById(R.id.ibtn_show_market_place);
		}

		/**
		 * Basic methods
		 */

		private void checkSellingIndex(AllItem allItem) {
			if (allItem.getSellingIndex() == Constants.SELLING_PRIVACY) {
				// Private collection
				mTvPrice.setText("");
				mIbtnShowMarketPlace
						.setImageResource(R.drawable.ibtn_market_place_normal);
				mIbtnShowAuction
						.setImageResource(R.drawable.ibtn_auction_normal);
			} else if (allItem.getSellingIndex() == Constants.SELLING_AUCTION
					&& mAlItemID.contains(allItem.getShotid())) {
				// Auction collection
				int index_shot_id = mAlItemID.indexOf(allItem.getShotid());
				Information information = mAlInformation.get(index_shot_id);

				mTvPrice.setText(information.getBasePrice() + Constants.RATE);

				mIbtnShowMarketPlace
						.setImageResource(R.drawable.ibtn_market_place_normal);
				mIbtnShowAuction
						.setImageResource(R.drawable.ibtn_auction_checked);
			} else if (allItem.getSellingIndex() == Constants.SELLING_MARKET_PLACE
					&& mAlItemID.contains(allItem.getShotid())) {
				// Market Place collection
				int index_shot_id = mAlItemID.indexOf(allItem.getShotid());
				Information information = mAlInformation.get(index_shot_id);

				mTvPrice.setText(information.getPrice() + Constants.RATE);

				mIbtnShowMarketPlace
						.setImageResource(R.drawable.ibtn_market_place_checked);
				mIbtnShowAuction
						.setImageResource(R.drawable.ibtn_auction_normal);
			}
		}

		private void getAuctionData(final AllItem allItem) {
			if (allItem.getSellingIndex() == Constants.SELLING_MARKET_PLACE) {
				All.mAdAuction.show();
			} else {
				// Initial variables
				initialVariables(All.mDialogAuction);
				initialData(All.mDialogAuction);

				submittedData = new SubmittedData();

				allItemAuction = allItem;

				/**
				 * Initial Country adapter Begin get Country name and Country ID
				 */
				if (All.mAaCountryAdapter == null) {
					All.mAaCountryAdapter = getCountryAdapter();
				}

				/**
				 * Set data for spinner auction period
				 */
				final CustomAuctionPeriodAdapter customAuctionPeriodAdapter = new CustomAuctionPeriodAdapter(
						context, R.layout.simple_spinner_item, context
								.getResources().getStringArray(
										R.array.auction_period));
				mSpinnerAuctionPeriod.setAdapter(customAuctionPeriodAdapter);
				mSpinnerAuctionPeriod
						.setOnItemSelectedListener(spinnerAuctionDialogListener);

				/**
				 * Get information
				 */
				final Information information;
				if (allItem.getSellingIndex() == Constants.SELLING_AUCTION
						&& mAlItemID.contains(allItem.getShotid())) {
					// Auction Collection
					int index_shot_id = mAlItemID.indexOf(allItem.getShotid());
					information = mAlInformation.get(index_shot_id);

					// Set data for these views
					mEtBasePriceAuction.setText(information.getBasePrice());
					
					mEtBuyNowPriceAuction.setText(information.getBuyNowPrice());
					mEtAssociationAuction.setText(allItem.getAssociation());
					mEtCamcorderModelAuction.setText(allItem.getCamcorderModel());
					mEtCityAuction.setText(allItem.getCity());
					mEtJournalistIDAuction.setText(allItem.getJournalistID());
					mEtDescriptionAuction.setText(information.getDesc());
					mEtTitleAuction.setText(information.getTitle());

					// Set auction period
					AUCTION_PERIOD = information.getAuctionPeriod();

					// If item has existed, set auction period
					customAuctionPeriodAdapter.setAuctionPeriod(AUCTION_PERIOD);

					// Show Country item on Market Place dialog
					DEFAULT_COUNTRY_ID = Integer.valueOf(information
							.getCountryID());

					// Choose TAGS right
					String[] TAGS = information.getTags().split(",");
					for (String tags : TAGS) {
						setCheckedTagsAuction(tags);
					}

					// If the auction values have submitted, set submitted
//					mBtnSubmitAuction.setEnabled(false);
					mBtnSubmitAuction.setText(context.getString(R.string.submit));

					/**
					 * If this item already had Base Price and Buy Now
					 * Price, Auction spinner Not allow edit
					 */
					mEtBasePriceAuction.setEnabled(false);
					mEtBuyNowPriceAuction.setEnabled(false);
					mSpinnerAuctionPeriod.setEnabled(false);
				} else {
					// Private collection & Market place collection
					// Set default value
					mEtAssociationAuction.setText("");
					mEtBasePriceAuction.setText(context
							.getString(R.integer.DEFAUL_BASE_PRICE_IN_AUCTION));
					mEtBuyNowPriceAuction.setText(context
							.getString(R.integer.DEFAUL_BASE_PRICE_IN_AUCTION));
					mEtCamcorderModelAuction.setText("");
					mEtCityAuction.setText("");
					mEtDescriptionAuction.setText(allItem.getMemo());
					mEtJournalistIDAuction.setText("");
					mEtTitleAuction.setText(allItem.getFileName());

					/**
					 * If this item not already had Base Price and Buy Now
					 * Price, Auction spinner allow edit
					 */
					mEtBasePriceAuction.setEnabled(true);
					mEtBuyNowPriceAuction.setEnabled(true);
					mSpinnerAuctionPeriod.setEnabled(true);

					// If the auction values have submitted, set submit
					mBtnSubmitAuction.setEnabled(true);
					mBtnSubmitAuction.setText(context
							.getString(R.string.submit));
				}

				/**
				 * Set Country Listener
				 */
				// Set adapter for Country Spinner
				mSpinnerCountry.setAdapter(All.mAaCountryAdapter);
				// Set selected listener for the item
				mSpinnerCountry
						.setOnItemSelectedListener(new SpinnerCountryListener());

				// Submit button
				mBtnSubmitAuction.setOnClickListener(mListenerSubmitAuction);

				// Remove button
				mBtnRemoveAuction.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						submittedData.setItemID(allItem.getShotid());

						new GetTokenString(context, false).execute();
						// Temporary, not used
						new RemoveItemAsync(context).execute(submittedData);

						// Dismiss dialog
						All.mDialogAuction.dismiss();
					}
				});

				// Cancel button
				mIbtnCancelAuction.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						All.mDialogAuction.dismiss();
					}
				});

				// Show auction dialog
				All.mDialogAuction.show();
			}
		}

		private void getCheckedTagsAuction() {
			if (mCbEntertainmentAuction.isChecked()) {
				submittedData.setTags(mCbEntertainmentAuction.getText()
						.toString());
			}
			if (mCbLifestyleAuction.isChecked()) {
				submittedData.setTags(mCbLifestyleAuction.getText().toString());
			}
			if (mCbPoliticsAuction.isChecked()) {
				submittedData.setTags(mCbPoliticsAuction.getText().toString());
			}
			if (mCbSportsAuction.isChecked()) {
				submittedData.setTags(mCbSportsAuction.getText().toString());
			}
			if (mCbTechnologyAuction.isChecked()) {
				submittedData
						.setTags(mCbTechnologyAuction.getText().toString());
			}
		}

		private void getCheckedTagsMarketPlace() {
			/**
			 * TODO Check Category isChecked right or not
			 */
			
			if (mCbEntertainmentMarketPlace.isChecked()) {
				submittedData.setTags(mCbEntertainmentMarketPlace.getText()
						.toString());
			}
			if (mCbLifestyleMarketPlace.isChecked()) {
				submittedData.setTags(mCbLifestyleMarketPlace.getText()
						.toString());
			}
			if (mCbPoliticsMarketPlace.isChecked()) {
				submittedData.setTags(mCbPoliticsMarketPlace.getText()
						.toString());
			}
			if (mCbSportsMarketPlace.isChecked()) {
				submittedData
						.setTags(mCbSportsMarketPlace.getText().toString());
			}
			if (mCbTechnologyMarketPlace.isChecked()) {
				submittedData.setTags(mCbTechnologyMarketPlace.getText()
						.toString());
			}
		}

		/**
		 * Basic Methods
		 */
		private ArrayAdapter<String> getCountryAdapter() {
			// read from *.csv file
			List<String[]> mListCsvItem = readCsvFile();
			ArrayList<String> mAlCountryTempItem = null;

			// Clear data
			All.mAlCountryNameItem.clear();

			String[] COLUMN = null;
			// Get string[] lists
			for (String[] lists : mListCsvItem) {
				for (String lines : lists) {
					COLUMN = lines.split(";");

					// Set country name array, need fix symbol \"
					All.mAlCountryNameItem
							.add(COLUMN[Constants.FILE_CSV_COUNTRY_NAME_COLUMN]
									.replace("\"", ""));
				}
			}

			// Copy to new array list
			mAlCountryTempItem = new ArrayList<String>(All.mAlCountryNameItem);

			// Sort country name
			Collections.sort(mAlCountryTempItem);

			// Convert from array list to string[] array
			String[] COUNTRY_NAME_ITEM = new String[mAlCountryTempItem.size()];
			for (int i = 0; i < mAlCountryTempItem.size(); i++) {
				COUNTRY_NAME_ITEM[i] = mAlCountryTempItem.get(i);
			}

			// Set adapter in here
			return new ArrayAdapter<String>(context,
					R.layout.simple_spinner_item, COUNTRY_NAME_ITEM);
		}

		private void getInfoData(final AllItem video) {
			// Initial variables in info dialog
			initialVariables(All.mDialogInfo);

			// Initial full dialog for setting full window
			initialData(All.mDialogInfo);

			// item information
			final Information information;
			// Get type of sale, note : shot_id and video_id is same
			if (video.getSellingIndex() == Constants.SELLING_PRIVACY) {
				// 0: Private collection

				mTvFileNameInfo.setText(video.getFileName());
				mTvStatusInfo.setText(context
						.getString(R.string.private_collection_info));
				mTvDescriptionInfo.setText(video.getMemo());
			} else if (video.getSellingIndex() == Constants.SELLING_AUCTION
					&& mAlItemID.contains(video.getShotid())) {
				// 1 : Auction collection

				// Get index of video id through shot id
				int index = mAlItemID.indexOf(video.getShotid());
				information = mAlInformation.get(index);

				// Hide these views
				mLlFixedPrice.setVisibility(View.GONE);
				mLlSold.setVisibility(View.GONE);

				// Show these views
				mLlExpiryTime.setVisibility(View.VISIBLE);
				mLlHighestBid.setVisibility(View.VISIBLE);
				mLlMinimumBid.setVisibility(View.VISIBLE);

				// Set data for these views
				mTvDescriptionInfo.setText(information.getDesc());
				mTvExpiryTimeInfo.setText(information.getExpiryTime());
				mTvFileNameInfo.setText(information.getTitle());
				mTvHighestBidInfo.setText(information.getHighestBid()
						+ Constants.RATE);
				mTvMinimumBidInfo.setText(information.getMinimumBid()
						+ Constants.RATE);
				mTvStatusInfo.setText(context
						.getString(R.string.auction_status_info));

				if (information.getHighestBid().equals("")
						|| information.getHighestBid() == null) {
					mTvHighestBidInfo.setText("");
				} else {
					mTvHighestBidInfo.setText(information.getHighestBid()
							+ Constants.RATE);
				}
			} else if (video.getSellingIndex() == Constants.SELLING_MARKET_PLACE
					&& mAlItemID.contains(video.getShotid())) {
				// 2 : Market place collection

				// Get index of video id through shot id
				int index_shot_id = mAlItemID.indexOf(video.getShotid());
				information = mAlInformation.get(index_shot_id);

				// Show these views
				mLlFixedPrice.setVisibility(View.VISIBLE);
				mLlSold.setVisibility(View.VISIBLE);

				// Hide these views
				mLlExpiryTime.setVisibility(View.GONE);
				mLlHighestBid.setVisibility(View.GONE);
				mLlMinimumBid.setVisibility(View.GONE);

				// Set data for that views
				mTvStatusInfo.setText(context
						.getString(R.string.market_place_status_info));
				mTvFileNameInfo.setText(information.getTitle());
				mTvDescriptionInfo.setText(information.getDesc());
				mTvFixedPriceInfo.setText(information.getPrice()
						+ Constants.RATE);
				mTvSoldInfo.setText(information.getSold() + " units ");
			}

			mIbtnCancelInfo.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					All.mDialogInfo.dismiss();
				}
			});
			// Set full dialog
			All.mDialogInfo.show();
		}

		private void getMarketPlaceData(final AllItem allItem) {
			if (allItem.getSellingIndex() == Constants.SELLING_AUCTION) {
				// If item has already chosen by Auction item,
				// show alert dialog
				All.mAdMarketPlace.show();
			} else {
				// MarketPlace
				// Define variables
				initialVariables(All.mDialogMarketPlace);
				initialData(All.mDialogMarketPlace);

				// Create object to store value before submitting to server
				submittedData = new SubmittedData();
				// Item information
				final Information information;
				allItemMarketPlace = allItem;

				/**
				 * Initial Country adapter Begin get Country name and Country ID
				 */
				if (All.mAaCountryAdapter == null) {
					All.mAaCountryAdapter = getCountryAdapter();
				}

				/**
				 * Check Item already existed on Market Place or not
				 */
				if (allItem.getSellingIndex() == Constants.SELLING_MARKET_PLACE
						&& mAlItemID.contains(allItem.getShotid())) {
					// Market place collection

					/**
					 * If the item already existed on Market Place Get
					 * information from the server
					 */

					int index_shot_id = mAlItemID.indexOf(allItem.getShotid());
					information = mAlInformation.get(index_shot_id);

					// Set these data for views
					mEtAssociationMarketPlace.setText(allItem.getAssociation());
					mEtCamcorderModelMarketPlace.setText(allItem
							.getCamcorderModel());
					mEtCityMarketPlace.setText(allItem.getCity());
					mEtDescriptionMarketPlace.setText(information.getDesc());
					mEtJournalistIDMarketPlace.setText(allItem
							.getJournalistID());
					mEtPriceMarketPlace.setText(information.getPrice());
					mEtTitleMarketPlace.setText(information.getTitle());

					// Show Country item on Market Place dialog
					DEFAULT_COUNTRY_ID = Integer.valueOf(information
							.getCountryID());

					// Choose right TAGS
					String[] TAGS = information.getTags().split(",");
					for (String tags : TAGS) {
						setCheckedTagsMarketPlace(tags);
					}

					// Set Submit button to Resubmit button
					mBtnSubmitMarketPlace.setText(context
							.getString(R.string.resubmit));
				} else {
					/**
					 * If the item not already existed on Market Place Set
					 * default information for these items in below
					 */
					mEtAssociationMarketPlace.setText("");
					mEtCamcorderModelMarketPlace.setText("");
					mEtCityMarketPlace.setText("");
					mEtDescriptionMarketPlace.setText(allItem.getMemo());
					mEtJournalistIDMarketPlace.setText("");
					mEtTitleMarketPlace.setText(allItem.getFileName());
					mEtPriceMarketPlace
							.setText(DefaultValue.DEFAULT_PRICE + "");

					mBtnSubmitMarketPlace.setText(context
							.getString(R.string.submit));
				}

				/**
				 * Set Country Listener
				 */
				// Set adapter for Country Spinner
				mSpinnerCountry.setAdapter(All.mAaCountryAdapter);
				// Set selected listener for the item
				mSpinnerCountry
						.setOnItemSelectedListener(new SpinnerCountryListener());

				/**TODO
				 * On Click Listener
				 */
				// On clicked
				mBtnSubmitMarketPlace
						.setOnClickListener(mListenerSubmitMarketPlace);

				// Remove button
				mBtnRemoveMarketPlace.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						submittedData.setItemID(allItem.getShotid());

						new GetTokenString(context, false).execute();

						// Remove data from the server
						new RemoveItemAsync(context).execute(submittedData);

						// Dismiss dialog
						All.mDialogMarketPlace.dismiss();
					}
				});

				mIbtnCancelMarketPlace
						.setOnClickListener(new OnClickListener() {

							@Override
							public void onClick(View v) {
								All.mDialogMarketPlace.dismiss();
							}
						});

				// Finally, show market place dialog
				All.mDialogMarketPlace.show();
			}
		}

		@SuppressWarnings("resource")
		public final List<String[]> readCsvFile() {
			List<String[]> questionList = new ArrayList<String[]>();
			AssetManager assetManager = context.getAssets();

			try {
				InputStream csvStream = assetManager.open(Constants.FILE_CSV);
				InputStreamReader csvStreamReader = new InputStreamReader(
						csvStream);
				CSVReader csvReader = new CSVReader(csvStreamReader);
				String[] line;

				while ((line = csvReader.readNext()) != null) {
					questionList.add(line);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			return questionList;
		}

		private void setCheckedTagsAuction(String tags) {
			// Set tags into submitted data
			if (tags.equals(context.getString(R.string.tag_entertainment))) {
				mCbEntertainmentAuction.setChecked(true);

				submittedData.setTags(mCbEntertainmentAuction.getText()
						.toString());
			}
			if (tags.equals(context.getString(R.string.tag_lifestyle))) {
				mCbLifestyleAuction.setChecked(true);

				submittedData.setTags(mCbLifestyleAuction.getText().toString());
			}
			if (tags.equals(context.getString(R.string.tag_politics))) {
				mCbPoliticsAuction.setChecked(true);

				submittedData.setTags(mCbPoliticsAuction.getText().toString());
			}
			if (tags.equals(context.getString(R.string.tag_sports))) {
				mCbSportsAuction.setChecked(true);

				submittedData.setTags(mCbSportsAuction.getText().toString());
			}
			if (tags.equals(context.getString(R.string.tag_technology))) {
				mCbTechnologyAuction.setChecked(true);

				submittedData
						.setTags(mCbTechnologyAuction.getText().toString());
			}
		}

		private void setCheckedTagsMarketPlace(String tags) {
			/**
			 * Check tags equal either of following contents to show on dialog
			 */
			if (tags.equals(context.getString(R.string.tag_entertainment))) {
				mCbEntertainmentMarketPlace.setChecked(true);

				submittedData.setTags(mCbEntertainmentMarketPlace.getText()
						.toString());
			}
			if (tags.equals(context.getString(R.string.tag_lifestyle))) {
				mCbLifestyleMarketPlace.setChecked(true);

				submittedData.setTags(mCbLifestyleMarketPlace.getText()
						.toString());
			}
			if (tags.equals(context.getString(R.string.tag_politics))) {
				mCbPoliticsMarketPlace.setChecked(true);

				submittedData.setTags(mCbPoliticsMarketPlace.getText()
						.toString());
			}
			if (tags.equals(context.getString(R.string.tag_sports))) {
				mCbSportsMarketPlace.setChecked(true);

				submittedData.setTags(mCbSportsMarketPlace.getText()
						.toString());
			}
			if (tags.equals(context.getString(R.string.tag_technology))) {
				mCbTechnologyMarketPlace.setChecked(true);

				submittedData.setTags(mCbTechnologyMarketPlace.getText()
						.toString());
			}
		}

		/**
		 * Classes
		 */
		
		public class SpinnerAuctionDialogListener implements
				OnItemSelectedListener {

			private String AUCTION_PERIOD_ITEM = null;

			@Override
			public void onItemSelected(AdapterView<?> parent, View view,
					int pos, long id) {
				TextView mTvAuctionPeriod = (TextView) view
						.findViewById(R.id.tv_spinner_item);

				AUCTION_PERIOD_ITEM = parent.getItemAtPosition(pos).toString();

				if (AUCTION_PERIOD != null) {
					mTvAuctionPeriod.setText(AUCTION_PERIOD + " mins");

					AUCTION_PERIOD = null;
				} else
					mTvAuctionPeriod.setText(AUCTION_PERIOD_ITEM);
			}

			@Override
			public void onNothingSelected(AdapterView<?> parent) {
				Log.i(TAG, "onNothingSelected");
			}

			public String getAuctionPeriod() {
				return AUCTION_PERIOD_ITEM;
			}
		}

		/**
		 * Listener for Country Spinner
		 */
		public class SpinnerCountryListener implements OnItemSelectedListener {

			private boolean IS_FIRST_TIME = true;

			@Override
			public void onItemSelected(AdapterView<?> adapterView, View v,
					int position, long id) {

				final TextView mTvCountry = (TextView) v
						.findViewById(R.id.tv_spinner_item);
				/**
				 * In the first time open dialog, check DEFAULT_COUNTRY_ID
				 * already changed value Country Name or not
				 */
				if (IS_FIRST_TIME) {
					if (DEFAULT_COUNTRY_ID != 0) {
						// Get selected name via selected index id
						mTvCountry
								.setText(getSelectedIndexName(DEFAULT_COUNTRY_ID - 1));
						getSelectedIndexItem(mTvCountry);

						// Reset all things
						DEFAULT_COUNTRY_ID = 0;
					} else {
						mTvCountry.setText(adapterView.getItemAtPosition(
								DefaultValue.DEFAULT_COUNTRY_ID - 1) + "");
						getSelectedIndexItem(mTvCountry);
					}

					// Reset all things
					IS_FIRST_TIME = false;
				} else {
					mTvCountry.setText(adapterView.getItemAtPosition(position)
							+ "");
					getSelectedIndexItem(mTvCountry);
				}
			}

			@Override
			public void onNothingSelected(AdapterView<?> parent) {
			}

			public String getCountryID() {
				return SELECTED_COUNTRY_ID + "";
			}

			public void getSelectedIndexItem(TextView tv) {
				for (int i = 0; i < All.mAlCountryNameItem.size(); i++) {
					if (tv.getText().toString()
							.equals(All.mAlCountryNameItem.get(i))) {
						// Set country id & country name,
						// for sending to the server
						int INDEX_COUNTRY_ID = i + 1;
						SELECTED_COUNTRY_ID = INDEX_COUNTRY_ID + "";

						break;
					}
				}
			}

			public String getSelectedIndexName(int index) {
				return All.mAlCountryNameItem.get(index);
			}
		}
	}
}
